/***************************************************************************
 *   Copyright (C) 2006 by Harish Kukreja                                  *
 *   harish.kukreja@gmail.com                                              *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

//
// C++ Interface: collision
//
// Description: Collision detection & reaction functions and objects.
//
//
// Author: Harish Kukreja <harish.kukreja@gmail.com>, (C) 2006
//
// Copyright: See COPYING file that comes with this distribution
//
//


#ifndef _PHYSIKS_COLLISION_H_
#define _PHYSIKS_COLLISION_H_

#include <physiksbase/world.h>

namespace PhysiksBase {

namespace Collisions {
    using PhysiksBase::World;
    using PhysiksBase::PhysicalObject;
    using PhysiksBase::Sphere;
    using PhysiksBase::Plane;
    
    /** Detect collisions among various PhysicalObjects within a world. */
    bool detect_collisions(const World &world);
    
    /** Check for a collision between the given point and sphere. */
    bool detect_point_sphere(const PhysicalObject &obj, const Sphere &sph);
    
    /** Check for a collision between the given point and plane. */
    bool detect_point_plane(const PhysicalObject &obj, const Plane &plane);
    
    /** Check for a collision between two spheres. */
    bool detect_sphere_sphere(const Sphere &sph1, const Sphere &sph2);
    
    /** Check for a collision between the given sphere and plane. */
    bool detect_sphere_plane(const Sphere &sphere, const Plane &plane);
    
    
    /** Each of the following functions adjusts the force vectors of its
     * parameters based on the relevant collision information (e.x. positions
     * of objects relative to each other, elasticity of spheres, etc.)  */
    void react_point_sphere(PhysicalObject &obj, Sphere &sph);
    void react_point_plane(PhysicalObject &obj, Plane &plane);
    void react_sphere_sphere(Sphere &sph1, Sphere &sph2);
    void react_sphere_plane(Sphere &sphere, Plane &plane);
    
}   // End of namespace Collisions
}   // End of namespace PhysiksBase

#endif
